<%@page import="com.is.model.User"%>
<%@page import="com.is.control.ParamClassControl"%>
<%@page import="com.is.control.ParamCourseControl"%>
<%@page import="com.is.control.CourseClassControl"%>
<%@page import="com.is.control.TeacherAssessControl"%>
<%@page import="com.is.model.TeacherAssess"%>
<%@page import="java.util.List"%>
<%@page import="com.is.control.ParamStuyearControl"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.is.util.ParamUtil"%>
<%@page import="com.is.util.DateTime"%>
<%@page import="com.is.control.UserControl"%>
<%@page import="com.is.model.CourseClass"%>
<%@page import="java.util.Map"%>
<%@page import="com.is.export.model.AssessExport"%>
<%@page import="java.util.ArrayList"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/InterStu/resources/image/favicon.ico" />
<script type="text/javascript" src="../../resources/js/WebCalendar.js"></script>
<link rel="stylesheet" type="text/css" href="../../resources/css/all.css" />
<link href="../../resources/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../resources/js/jquery-1.8.1.js"></script>
<script type="text/javascript" src="../../resources/js/jquery.artDialog.js"></script>
<script type="text/javascript" src="../../resources/js/iframeTools.js"></script>
<script type="text/javascript">
	(function (config) {
	    config['fixed'] = true;
	    config['okVal'] = '确定';
	    config['cancelVal'] = '取消';
		config['skin'] = 'default';
		config['drag'] = 'true';
	    // [more..]
	})(art.dialog.defaults);
	$(function(){
		var block = $("#magic_block");
		if($(".active a").position()){
			block.css("top",$(".active a").position().top+10)
			.data("oriTop",$(".active a").position().top)
		}
		$(".nav ul li").find("a").hover(
			function(){
				var $this = $(this);
				var newTop = $this.position().top;
				block.stop().animate({
					top:newTop+10
				})
			},
			function(){
				block.stop().animate({
					top:block.data("oriTop")+10
				})
			}
		)
		/**/
		$("#add_assess").hide();
		$(".add_btn").click(function(){
			var id = $(this).attr("rel");
			var url = "teacher_single_add_do.jsp?id=" + id;
			$(".add_name").html($(this).parent().prev().prev().prev().prev().prev().prev().prev().html());
			$("input[name='u_id']").val($(this).prev().val());
			$("input[name='course_class_id']").val($(this).prev().prev().val())
			document.forms["add_form"].action = url;
			$.dialog({
				title:"添加考核",
				content:document.getElementById("add_assess")
			})
		})
		/*numonly*/
		var numreg = /^\d+\.?\d*$/;
		$("input[type='text']").bind("input",function(){
			if(!numreg.test($(this).val())){
				var tem = $(this).val().substring(0,$(this).val().length-1)
				$(this).val(tem);
			}
		})
		var h = $(".right").height();
		$(".left").height(h);
		$(".update").click(function(){
			$.dialog.open("/InterStu/update_info.jsp",{width:460,height:400,title:"个人信息"});
		})
		$('img').error(function(){
			this.src = "/InterStu/resources/image/man.GIF";
		})
	})
</script>
<title>留学生预科班</title>
</head>
<% 
	 User cu =(User)session.getAttribute("user"); 
     String time1 = DateTime.SimpleDate();
     if(ParamStuyearControl.getStuyearIdByTime(DateTime.SimpleDate())!=0){
        time1 = ParamUtil.getString(request,"time1",ParamStuyearControl.getStuyear(ParamStuyearControl.getStuyearIdByTime(DateTime.SimpleDate())).getStartTime());//默认为本学期开学时间
     }
     String time2 = ParamUtil.getString(request,"time2",DateTime.SimpleDate());
     int uid = ParamUtil.getInt(request,"uid",0);//要查看的老师id
     List<AssessExport> exportList = new ArrayList<AssessExport>();
%>
<body>
<div class="header">
	<div class="title pr">
    	<a href="javascript:void(0);"><span class="update pa">个人信息</span></a>
        <span class="logout pa"><a class="hide" href="/InterStu/login/logout.jsp">退出</a></span>
    </div>
</div>
<div class="main">
	<div class="left">  
	   <div class="infomation">
			<div class="photo">
			<%
			String picUrl = cu.getPicUrl();
			if(session.getAttribute("picUrl")!=null){
			    picUrl = "/InterStu/User/UserHeadImage/"+(String)session.getAttribute("picUrl");
			}	
			%>
				<img width='60' height="60" src = "<%=picUrl %>"  />
			</div>
			<div class="welcome">
				<%=cu.getName() %>,<br/>
				欢迎您使用！
			</div>
		</div>  	   	  	
    	<div class="nav">
        	<ul>	
            	<%if(cu!=null&&cu.getRole().equals("1")){ %>
            	<li class="pa" id="magic_block"></li>
                <li><a href="/InterStu/pages/stuyear/stuyear_start.jsp">新学期设置</a></li>
                <li><a href="/InterStu/pages/users/user_all.jsp">用户管理</a></li>
                <%} %>
                <li><a href="/InterStu/pages/students/student_add.jsp">学生管理</a></li>
                <li ><a href="/InterStu/pages/dictation/dictation_add.jsp">学生考核</a></li>
                <%if(cu!=null&&cu.getRole().equals("1")){ %>
                <li class="active"><a href="/InterStu/pages/assess/teacher_assess.jsp">教职人员管理</a></li>
                <%} %>
            </ul>
        </div>
    </div>
    <div class="right">
    	<div class="r1">
    	<table class="teacher tab">
	    <tr>
	    	<td>
	    		<a class="current" href="/InterStu/pages/assess/teacher_assess.jsp">查看考核</a>
			</td>
			<td>
				<a href="/InterStu/pages/assess/teacher_assess_add.jsp">添加考核</a>
			</td>
	    </tr>
	    </table>
    	<form action="teacher_assess.jsp" method="post">
		<table class="table">
			<caption>请选择</caption>
			<tr>
				<td>开始时间</td>
				<td><input id="time1" type='text'  name="time1" onclick="SelectDate(this,'','','yyyy-MM-dd')"  readonly style="cursor:pointer"  value="<%=time1 %>"/></td>
		        <td>结束时间</td>
		        <td><input id="time2" type='text'  name="time2" onclick="SelectDate(this,'','','yyyy-MM-dd')"  readonly style="cursor:pointer"  value="<%=time2 %>"/></td>
		        <td><input type="submit" value="查询"/></td>
	        </tr>
        </table>
		</form>
        </div>
        <div class="r2">
        <table class="table">
		<caption><%= time1 %>至<%=time2%>期间,教职工考核情况如下【<a href="export_deal.jsp" target="_blank">导出查询结果</a>】</caption>
		<thead>
		<tr>
		<th>教工</th>
		<th>课程</th>
		<th>班级</th>
		<th>此期间工作量(/课时)</th>
		<th>缺勤(/课时)</th>
		<th>额外(/课时)</th>
		<th>请假(/课时)</th>
		<th>操作</th>
		</tr>
		</thead>
		<%
		   //此处考虑到一个老师可能有多个班级，所以，有可能出现多次
           List<User> users = UserControl.getAllUsersByRole("");
		  // System.out.print("SSS"+users.size());
		  int stuyear = ParamStuyearControl.getCurrentStuyearId();
           for(User u:users){
               List<CourseClass> ccs = CourseClassControl.getAllCourseClassIdByUidAndStuyear(u.getId(),stuyear);
	           System.out.println("DDD"+ccs.size());
	           if(ccs.size()>0){
	               for(CourseClass cc:ccs){
	            	   Map<String,String> map = TeacherAssessControl.countAmountPeriod(u.getId(),cc.getId(),time1,time2);
		           %>
		               <tr><td><%=u.getName() %></td>
			                <td><%out.print(cc.getCourseId()==0?"无":ParamCourseControl.getCourseById(cc.getCourseId()).getCourseName()) ;%> </td>
			                <td><%out.print(cc.getClassId()==0?"无":ParamClassControl.getClassName(cc.getClassId()));%></td>
			                <td><%=map.get("classAmount")%></td>
			                <td><%=map.get("absentAmount")%></td>
			                <td><%=map.get("extraAmount")%></td>
			                <td><%=map.get("leaveAmount")%></td>
			                <td>
			                <input type="hidden" value="<%=cc.getId() %>"/>
			                <input type="hidden" value="<%=u.getId() %>"/>
			                <a class="add_btn" href="javascript:void(0);" rel='<%=u.getId() %>'>添加</a></td>
		              </tr>
		           <%
		           AssessExport ae = new AssessExport();
		           ae.setCourseName(ParamCourseControl.getCourseById(cc.getCourseId()).getCourseName());
		           ae.setClassName(ParamClassControl.getClassName(cc.getClassId()));
		           ae.setEW(map.get("extraAmount"));
		           ae.setQJ(map.get("leaveAmount"));
		           ae.setQQ(map.get("absentAmount"));
		           ae.setTotalWork(map.get("classAmount"));
		           ae.setTeacherName(u.getName());
		           exportList.add(ae);
	               }
	           }else{
	        	   Map<String,String> map = TeacherAssessControl.countAmountPeriod(u.getId(),0,time1,time2);
	        	   %>
	               <tr>
		                <td><%=u.getName() %></td>
		                <td><%out.print("无") ;%> </td>
		                <td><%out.print("无");%></td>
		                <td><%=map.get("classAmount")%></td>
		                <td><%=map.get("absentAmount")%></td>
		                <td><%=map.get("extraAmount")%></td>
		                <td><%=map.get("leaveAmount")%></td>
		                <td>
		                <input type="hidden" value="0"/>
		                <input type="hidden" value="<%=u.getId() %>"/>
		                <a class="add_btn" href="javascript:void(0);" rel='<%=u.getId() %>'>添加</a>
		                </td>
	                </tr>
	                <%
	           }
           }
           
         session.removeAttribute("exportList");
       	 session.setAttribute("exportList",exportList);
       	 session.removeAttribute("fileName");
       	 session.setAttribute("fileName","教师考核");
		 %>
		</table>
        </div>
    </div>
    <div id="add_assess">
    	<form action="" name="add_form" method="post">
    	<table>
    	<tr>
    		<td>姓名</td>
    		<td><span class="add_name"></span></td>
    	</tr>
    	<tr>
    		<td>添加时间</td>
    		<td><input type="text" onclick="SelectDate(this,'','','yyyy-MM-dd')"  readonly style="cursor:pointer" name="t_time"  value=""/></td> 
    	</tr>
    	<tr>
    		<td>工作(/课时)</td>
    		<td><input type="text" name="t_work"  value="0.0"/></td> 
    	</tr>
    	<tr>
    		<td>缺勤(/课时)</td>
    		<td><input type="text" name="t_absent"   value="0.0"/></td> 
    	</tr>
    	<tr>
    		<td>额外(/课时)</td>
    		<td><input type="text" name="t_extra"   value="0.0"/></td> 
    	</tr>
    	<tr>
    		<td>请假(/课时)</td>
    		<td><input type="text" name="t_vacate"  value="0.0"/></td> 
    	</tr>
    	<tr>
    		<td colspan="2">
    			<input type="submit" value="确定"/>
    			<input type="hidden" name="u_id"/>
    			<input type="hidden" name="course_class_id"/>
    		</td>
    	</tr>
    	</table>
    	</form>
    </div>
</div>
<div class="footer">
	<p>版权所有：东北师范大学留学生预科部&nbsp;&nbsp;  蓝旭工作室开发</p>
</div>
</body>
</html>